<?php
//Chargement automatique de toutes les classes créées
function chargerClasse($class)
{
	require 'classes/'.$class.'.Class.php';
}
spl_autoload_register('chargerClasse');

//Connexion BDD
try
{
	if(Config::$ENV == "DEV")
	{
		$bdd = new PDO('mysql:host=localhost;dbname=kilbet','root','', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
	}
	elseif(Config::$ENV == "PROD")
	{
		$bdd = new PDO('mysql:host=mysql51-140.perso;dbname=kildevfrozdbadm','kildevfrozdbadm','Kilbet2014', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
	}
}
catch (Exception $e)
{
	die('Erreur :'.$e->getMessage());	
}



include_once('scripts/scripts.js');

session_start();


//Stockage valeur URL page précédente et page courante
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php';
$current = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : 'index.php';

if(isset($_GET['deconnect']) && ($_GET['deconnect']=="O"))
{
	session_destroy();
	header('Location: index.php');
}
else
{
	if(isset($_SESSION['userConnected'])) $userConnected = $_SESSION['userConnected'];
	if(isset($_SESSION['loginMessage'])) $loginMessage = $_SESSION['loginMessage'];
	if(isset($_SESSION['createAccountMessage'])) $createAccountMessage = $_SESSION['createAccountMessage'];
	if(isset($_SESSION['updateAccountMessage'])) $updateAccountMessage = $_SESSION['updateAccountMessage'];
	if(isset($_SESSION['lostPasswordMessage'])) $lostPasswordMessage = $_SESSION['lostPasswordMessage'];
}

$userManager=new UserManager($bdd);
$contestManager=new ContestManager($bdd);
$statusParticipationManager=new StatusParticipationManager($bdd);
$messageManager=new MessageManager($bdd);
$sportsManager=new SportManager($bdd);
$sportsEventManager=new SportsEventManager($bdd);
$eventManager=new EventManager($bdd);
$rulesContestManager=new RulesContestManager($bdd);
$scheduleEventManager=new ScheduleEventManager($bdd);
$betsManager=new BetsManager($bdd);

?>

